package com.itrus.raapi.implement;

import com.itrus.raapi.RaCertManager;
import com.itrus.raapi.RaConnection;
import com.itrus.raapi.RaFactory;
import com.itrus.raapi.exception.RaServiceUnavailable;
import com.itrus.raapi.info.CertInfo;
import com.itrus.raapi.info.PipeInteger;
import com.itrus.raapi.info.RenewInfo;
import com.itrus.raapi.info.UserInfo;
import com.itrus.raapi.result.DownloadCAResult;
import com.itrus.raapi.result.DownloadCRLResult;
import com.itrus.raapi.result.EnrollResult;
import com.itrus.raapi.result.OperationResult;
import com.itrus.raapi.result.PickupResult;
import com.itrus.raapi.result.QueryResult;
import com.itrus.raapi.result.RenewResult;
import com.itrus.raapi.result.RevokeResult;
import com.itrus.raapi.result.SqlResult;
import com.itrus.raapi.result.SuspendResult;
import com.itrus.raapi.result.UnSuspendResult;
import com.itrus.util.CertUtils;
import com.itrus.util.CipherUtils;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.Properties;
import java.util.Random;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class RaCertManagerImpl
  implements RaCertManager
{
  protected static Log log = LogFactory.getLog(RaCertManagerImpl.class);
  private String accountHash;
  private String accountOrg;
  private String accountOrgUnit;
  private Vector availableIcaServices = new Vector();
  protected int timeOut = 30;

  private void addUserInfoToProperties(UserInfo paramUserInfo, Properties paramProperties)
  {
    ifNotNullThenAdd(paramProperties, "USER_ID", paramUserInfo.getUserIdString());
    ifNotNullThenAdd(paramProperties, "ACCOUNT_ID", paramUserInfo.getAccountIdString());
    ifNotNullThenAdd(paramProperties, "USER_ID_RANDOM", paramUserInfo.getUserIdRandom());
    ifNotNullThenAdd(paramProperties, "USER_NAME", paramUserInfo.getUserName());
    ifNotNullThenAdd(paramProperties, "USER_SURNAME", paramUserInfo.getUserSurName());
    ifNotNullThenAdd(paramProperties, "CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(paramUserInfo.getUserSerialNumber()));
    ifNotNullThenAdd(paramProperties, "USER_EMAIL", paramUserInfo.getUserEmail());
    ifNotNullThenAdd(paramProperties, "USER_ORGANIZATION", paramUserInfo.getUserOrganization());
    ifNotNullThenAdd(paramProperties, "USER_ORGUNIT", paramUserInfo.getUserOrgUnit());
    ifNotNullThenAdd(paramProperties, "USER_COUNTRY", paramUserInfo.getUserCountry());
    ifNotNullThenAdd(paramProperties, "USER_STATE", paramUserInfo.getUserState());
    ifNotNullThenAdd(paramProperties, "USER_LOCALITY", paramUserInfo.getUserLocality());
    ifNotNullThenAdd(paramProperties, "USER_STREET", paramUserInfo.getUserStreet());
    ifNotNullThenAdd(paramProperties, "USER_DNS", paramUserInfo.getUserDns());
    ifNotNullThenAdd(paramProperties, "USER_IP", paramUserInfo.getUserIp());
    ifNotNullThenAdd(paramProperties, "USER_TITLE", paramUserInfo.getUserTitle());
    ifNotNullThenAdd(paramProperties, "USER_DESCRIPTION", paramUserInfo.getUserDescription());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD1", paramUserInfo.getUserAdditionalField1());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD2", paramUserInfo.getUserAdditionalField2());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD3", paramUserInfo.getUserAdditionalField3());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD4", paramUserInfo.getUserAdditionalField4());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD5", paramUserInfo.getUserAdditionalField5());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD6", paramUserInfo.getUserAdditionalField6());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD7", paramUserInfo.getUserAdditionalField7());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD8", paramUserInfo.getUserAdditionalField8());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD9", paramUserInfo.getUserAdditionalField9());
    ifNotNullThenAdd(paramProperties, "USER_ADDTIONAL_FIELD10", paramUserInfo.getUserAdditionalField10());
    ifNotNullThenAdd(paramProperties, "CERT_STATUS", paramUserInfo.getCertStatus());
    ifNotNullThenAdd(paramProperties, "CERT_NOTBEFORE", paramUserInfo.getCertNotBefore());
    ifNotNullThenAdd(paramProperties, "CERT_NOTAFTER", paramUserInfo.getCertNotAfter());
    ifNotNullThenAdd(paramProperties, "CERT_REQ_OVERRIDE_VALIDITY", paramUserInfo.getCertReqOverrideValidity());
    ifNotNullThenAdd(paramProperties, "CERT_REQ_BUF", paramUserInfo.getCertReqBuffer());
    ifNotNullThenAdd(paramProperties, "CERT_REQ_CHALLENGE", paramUserInfo.getCertReqChallenge());
    ifNotNullThenAdd(paramProperties, "CERT_REQ_COMMENT", paramUserInfo.getCertReqComment());
    ifNotNullThenAdd(paramProperties, "CERT_KMC_REQ2", paramUserInfo.getCertKmcReq2());
  }

  private CertInfo getCertInfo(Properties paramProperties)
  {
    CertInfo localCertInfo = new CertInfo();
    localCertInfo.setUserStrId(paramProperties.getProperty("USER_ID"));
    localCertInfo.setAccountStrId(paramProperties.getProperty("ACCOUNT_ID"));
    localCertInfo.setUserIdRandom(paramProperties.getProperty("USER_ID_RANDOM"));
    localCertInfo.setUserName(paramProperties.getProperty("USER_NAME"));
    localCertInfo.setUserSurName(paramProperties.getProperty("USER_SURNAME"));
    localCertInfo.setUserSerialNumber(paramProperties.getProperty("USER_SERIALNUMBER"));
    localCertInfo.setUserEmail(paramProperties.getProperty("USER_EMAIL"));
    localCertInfo.setUserOrganization(paramProperties.getProperty("USER_ORGANIZATION"));
    localCertInfo.setUserOrgUnit(paramProperties.getProperty("USER_ORGUNIT"));
    localCertInfo.setUserCountry(paramProperties.getProperty("USER_COUNTRY"));
    localCertInfo.setUserState(paramProperties.getProperty("USER_STATE"));
    localCertInfo.setUserLocality(paramProperties.getProperty("USER_LOCALITY"));
    localCertInfo.setUserStreet(paramProperties.getProperty("USER_STREET"));
    localCertInfo.setUserDns(paramProperties.getProperty("USER_DNS"));
    localCertInfo.setUserIp(paramProperties.getProperty("USER_IP"));
    localCertInfo.setUserTitle(paramProperties.getProperty("USER_TITLE"));
    localCertInfo.setUserDescription(paramProperties.getProperty("USER_DESCRIPTION"));
    localCertInfo.setUserAdditionalField1(paramProperties.getProperty("USER_ADDTIONAL_FIELD1"));
    localCertInfo.setUserAdditionalField2(paramProperties.getProperty("USER_ADDTIONAL_FIELD2"));
    localCertInfo.setUserAdditionalField3(paramProperties.getProperty("USER_ADDTIONAL_FIELD3"));
    localCertInfo.setUserAdditionalField4(paramProperties.getProperty("USER_ADDTIONAL_FIELD4"));
    localCertInfo.setUserAdditionalField5(paramProperties.getProperty("USER_ADDTIONAL_FIELD5"));
    localCertInfo.setUserAdditionalField6(paramProperties.getProperty("USER_ADDTIONAL_FIELD6"));
    localCertInfo.setUserAdditionalField7(paramProperties.getProperty("USER_ADDTIONAL_FIELD7"));
    localCertInfo.setUserAdditionalField8(paramProperties.getProperty("USER_ADDTIONAL_FIELD8"));
    localCertInfo.setUserAdditionalField9(paramProperties.getProperty("USER_ADDTIONAL_FIELD9"));
    localCertInfo.setUserAdditionalField10(paramProperties.getProperty("USER_ADDTIONAL_FIELD10"));
    localCertInfo.setCertStrId(paramProperties.getProperty("CERT_ID"));
    localCertInfo.setCertIdRandom(paramProperties.getProperty("CERT_ID_RANDOM"));
    localCertInfo.setCertStatus(paramProperties.getProperty("CERT_STATUS"));
    localCertInfo.setCertReqDate(paramProperties.getProperty("CERT_REQ_DATE"));
    localCertInfo.setCertReqTransid(paramProperties.getProperty("CERT_REQ_TRANSID"));
    localCertInfo.setCertReqNonce(paramProperties.getProperty("CERT_REQ_NONCE"));
    localCertInfo.setCertReqBufType(paramProperties.getProperty("CERT_REQ_BUF_TYPE"));
    localCertInfo.setCertReqChallenge(paramProperties.getProperty("CERT_REQ_CHALLENGE"));
    localCertInfo.setCertReqComment(paramProperties.getProperty("CERT_REQ_COMMENT"));
    localCertInfo.setCertApproveDate(paramProperties.getProperty("CERT_APPROVE_DATE"));
    localCertInfo.setCertRejectDate(paramProperties.getProperty("CERT_REJECT_DATE"));
    localCertInfo.setCertSignDate(paramProperties.getProperty("CERT_SIGN_DATE"));
    localCertInfo.setCertSignBufP7(paramProperties.getProperty("CERT_SIGN_BUF_P7"));
    localCertInfo.setCertSerialNumber(paramProperties.getProperty("CERT_SERIALNUMBER"));
    localCertInfo.setCertNotBefore(paramProperties.getProperty("CERT_NOTBEFORE"));
    localCertInfo.setCertNotAfter(paramProperties.getProperty("CERT_NOTAFTER"));
    Date localDate1 = localCertInfo.getCertNotBeforeDate();
    Date localDate2 = localCertInfo.getCertNotAfterDate();
    if ((localDate1 != null) && (localDate2 != null))
    {
      Date localDate3 = new Date();
      if (((localDate3.before(localDate1)) || (localDate3.after(localDate2))) && ("VALID".equals(localCertInfo.getCertStatus())))
        localCertInfo.setCertStatus("OVERDUE");
    }
    localCertInfo.setCertIssuerHashMd5(paramProperties.getProperty("CERT_ISSUER_HASH_MD5"));
    localCertInfo.setCertIssuerDN(paramProperties.getProperty("CERT_ISSUER_DN"));
    localCertInfo.setCertSubjectHashMd5(paramProperties.getProperty("CERT_SUBJECT_HASH_MD5"));
    localCertInfo.setCertSubjectDN(paramProperties.getProperty("CERT_SUBJECT_DN"));
    localCertInfo.setCertSuspendDate(paramProperties.getProperty("CERT_SUSPEND_DATE"));
    localCertInfo.setCertRevokeDate(paramProperties.getProperty("CERT_REVOKE_DATE"));
    localCertInfo.setCertRevokeReason(paramProperties.getProperty("CERT_REVOKE_REASON"));
    localCertInfo.setCertRenewalDate(paramProperties.getProperty("CERT_RENEWAL_DATE"));
    localCertInfo.setCertRenewalPrevStrId(paramProperties.getProperty("CERT_RENEWAL_PREV_ID"));
    localCertInfo.setCertRenewalNextId(paramProperties.getProperty("CERT_RENEWAL_NEXT_ID"));
    localCertInfo.setCertReqOverrideValidity(paramProperties.getProperty("CERT_REQ_OVERRIDE_VALIDITY"));
    localCertInfo.setCertReqBuffer(paramProperties.getProperty("CERT_REQ_BUF"));
    localCertInfo.setCertSignBuf(paramProperties.getProperty("CERT_SIGN_BUF"));
    localCertInfo.setCertPin(paramProperties.getProperty("CERT_PIN"));
    localCertInfo.setCertType(paramProperties.getProperty("CERT_TYPE"));
    localCertInfo.setCertDeliverMode(paramProperties.getProperty("CERT_DELIVER_MODE"));
    localCertInfo.setCertApproveAdmin1(paramProperties.getProperty("CERT_APPROVE_ADMIN1"));
    localCertInfo.setCertApproveAdmin2(paramProperties.getProperty("CERT_APPROVE_ADMIN2"));
    localCertInfo.setCertRenewEmailDeliver(paramProperties.getProperty("CERT_RENEWEMAIL_DELIVER"));
    localCertInfo.setCertReqPublicKey(paramProperties.getProperty("CERT_REQ_PUBLICKEY"));
    localCertInfo.setCertReqPublicKeyHashMd5(paramProperties.getProperty("CERT_REQ_PUBLICKEY_HASH_MD5"));
    return localCertInfo;
  }

  private String getValidAdminCertSerialNumber()
    throws RaServiceUnavailable
  {
    SqlResult localSqlResult = new SqlResult();
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.put("OPERATION", "Query");
    localProperties1.put("SQL_TEMPLATE_FILENAME", "ra_SelectAdminByOOU");
    if ((this.accountOrg == null) && (this.accountOrgUnit == null))
      localProperties1.put("ACCOUNT_HASH", this.accountHash);
    RaConnection localRaConnection;
    String str;
    while (true)
    {
      localProperties1.put("ADMIN_STATUS", "VALID");
      localRaConnection = null;
      try
      {
        localRaConnection = getRaConnection(this.timeOut);
        long l = localRaConnection.request(localProperties1, localProperties2);
        localSqlResult.setReturnCode(l);
        if (l == 0L)
          localSqlResult.setSuccess(true);
        str = localProperties2.getProperty("ADMIN_CERT_SERIALNUMBER");
        if (str == null)
        {
          localSqlResult.setReturnCode("A002");
          localSqlResult.setExtMessage("缺少必要参数:ADMIN_CERT_SERIALNUMBER");
          return null;
          localProperties1.put("ADMIN_ORGANIZATION", this.accountOrg);
          localProperties1.put("ADMIN_ORGUNIT", this.accountOrgUnit);
        }
      }
      catch (IOException localIOException)
      {
        localSqlResult.setReturnCode(1L);
        return null;
      }
      finally
      {
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    if (localRaConnection != null)
      localRaConnection.close();
    return str;
  }

  private void ifNotExistThenAdd(Properties paramProperties, String paramString1, String paramString2)
  {
    if (paramProperties.getProperty(paramString1) == null)
      paramProperties.setProperty(paramString1, paramString2);
  }

  private void ifNotNullThenAdd(Properties paramProperties, String paramString1, String paramString2)
  {
    if ((paramString2 != null) && (!"".equals(paramString2)))
      paramProperties.setProperty(paramString1, paramString2);
  }

  private void setDownloadCAResultCharacter(Properties paramProperties, DownloadCAResult paramDownloadCAResult)
  {
    paramDownloadCAResult.setCACertBufP7(paramProperties.getProperty("CA_CERT_BUF_P7"));
    paramDownloadCAResult.setCAName(paramProperties.getProperty("CA_NAME"));
    paramDownloadCAResult.setCAOrganization(paramProperties.getProperty("CA_ORGANIZATION"));
    paramDownloadCAResult.setCAOrgUnit(paramProperties.getProperty("CA_ORGUNIT"));
    paramDownloadCAResult.setCASerialNumber(paramProperties.getProperty("CA_SERIALNUMBER"));
    paramDownloadCAResult.setCANotBefore(paramProperties.getProperty("CA_NOT_BEFORE"));
    paramDownloadCAResult.setCANotAfter(paramProperties.getProperty("CA_NOT_AFTER"));
    paramDownloadCAResult.setCAIssuerHashMD5(paramProperties.getProperty("CA_ISSUER_HASH_MD5"));
    paramDownloadCAResult.setCAIssuerDN(paramProperties.getProperty("CA_ISSUER_DN"));
    paramDownloadCAResult.setCASubjectHashMD5(paramProperties.getProperty("CA_SUBJECT_HASH_MD5"));
    paramDownloadCAResult.setCASubjectHashSHA1(paramProperties.getProperty("CA_SUBJECT_HASH_SHA1"));
    paramDownloadCAResult.setCACertBuf(paramProperties.getProperty("CA_CERT_BUF"));
  }

  private void setDownloadCRLResultCharacter(Properties paramProperties, DownloadCRLResult paramDownloadCRLResult)
  {
    paramDownloadCRLResult.setCRLBuf(paramProperties.getProperty("CRL_BUF"));
    paramDownloadCRLResult.setCAName(paramProperties.getProperty("CA_NAME"));
    paramDownloadCRLResult.setCASerialNumber(paramProperties.getProperty("CA_SERIALNUMBER"));
    paramDownloadCRLResult.setCRLLastUpdate(paramProperties.getProperty("CRL_LASTUPDATE"));
    paramDownloadCRLResult.setCRLNextUpdate(paramProperties.getProperty("CRL_NEXTUPDATE"));
    paramDownloadCRLResult.setCRLVersion(paramProperties.getProperty("CRL_VERSION"));
    paramDownloadCRLResult.setRevokeIDEnd(paramProperties.getProperty("REVOKE_ID_END"));
  }

  private void setPickupResultCharacter(Properties paramProperties, PickupResult paramPickupResult)
  {
    paramPickupResult.setCertApproveDate(paramProperties.getProperty("CERT_APPROVE_DATE"));
    paramPickupResult.setCertIssuerDN(paramProperties.getProperty("CERT_ISSUER_DN"));
    paramPickupResult.setCertIssuerHashMD5(paramProperties.getProperty("CERT_ISSUER_HASH_MD5"));
    paramPickupResult.setCertSubjectDN(paramProperties.getProperty("CERT_SUBJECT_DN"));
    paramPickupResult.setCertSubjectHashMD5(paramProperties.getProperty("CERT_SUBJECT_HASH_MD5"));
    paramPickupResult.setCertNotBefore(paramProperties.getProperty("CERT_NOTBEFORE"));
    paramPickupResult.setCertNotAfter(paramProperties.getProperty("CERT_NOTAFTER"));
    paramPickupResult.setCertReqDate(paramProperties.getProperty("CERT_REQ_DATE"));
    paramPickupResult.setCertSerialNumber(paramProperties.getProperty("CERT_SERIALNUMBER"));
    paramPickupResult.setCertSignBuf(paramProperties.getProperty("CERT_SIGN_BUF"));
    paramPickupResult.setCertSignBufP7(paramProperties.getProperty("CERT_SIGN_BUF_P7"));
    paramPickupResult.setCertSignDate(paramProperties.getProperty("CERT_SIGN_DATE"));
    paramPickupResult.setCertKmcReq2(paramProperties.getProperty("CERT_KMC_REQ2"));
    paramPickupResult.setCertKmcRep1(paramProperties.getProperty("CERT_KMC_REP1"));
    paramPickupResult.setCertKmcRep2(paramProperties.getProperty("CERT_KMC_REP2"));
    paramPickupResult.setCertKmcRep3(paramProperties.getProperty("CERT_KMC_REP3"));
  }

  private void setSqlResultCharacter(Properties paramProperties, SqlResult paramSqlResult)
  {
    paramSqlResult.setSqlRecordsCount(paramProperties.getProperty("SQL_RECORDS_COUNT"));
    paramSqlResult.setSqlRecordsIndex(paramProperties.getProperty("SQL_RECORDS_INDEX"));
    paramSqlResult.setSqlScriptRuntime(paramProperties.getProperty("SQL_SCRIPT_RUNTIME"));
  }

  public void addRaService(String paramString)
  {
    this.availableIcaServices.add(paramString);
  }

  public void addRaService(String paramString, int paramInt)
  {
    this.availableIcaServices.add("ica://" + paramString + ":" + paramInt);
  }

  public DownloadCAResult downloadCA()
    throws RaServiceUnavailable
  {
    DownloadCAResult localDownloadCAResult = new DownloadCAResult();
    if (this.accountHash == null)
    {
      localDownloadCAResult.setReturnCode("A002");
      localDownloadCAResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localDownloadCAResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.setProperty("OPERATION", "EEDownloadCA");
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localDownloadCAResult.setReturnCode(l);
      if (l == 0L)
        setDownloadCAResultCharacter(localProperties2, localDownloadCAResult);
      if (localRaConnection != null)
        localRaConnection.close();
      log.debug(localDownloadCAResult.getMessage());
      return localDownloadCAResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localDownloadCAResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public DownloadCRLResult downloadCRL()
    throws RaServiceUnavailable
  {
    DownloadCRLResult localDownloadCRLResult = new DownloadCRLResult();
    if (this.accountHash == null)
    {
      localDownloadCRLResult.setReturnCode("A002");
      localDownloadCRLResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localDownloadCRLResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.setProperty("OPERATION", "EEDownloadCRL");
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localDownloadCRLResult.setReturnCode(l);
      if (l == 0L)
        setDownloadCRLResultCharacter(localProperties2, localDownloadCRLResult);
      if (localRaConnection != null)
        localRaConnection.close();
      log.debug(localDownloadCRLResult.getMessage());
      return localDownloadCRLResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localDownloadCRLResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public OperationResult enrollCert(UserInfo paramUserInfo)
    throws RaServiceUnavailable
  {
    EnrollResult localEnrollResult = new EnrollResult();
    if (this.accountHash == null)
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localEnrollResult;
    }
    if ((paramUserInfo.getUserName() == null) || ("".equals(paramUserInfo.getUserName())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:USER_NAME（CommonName）");
      return localEnrollResult;
    }
    if ((paramUserInfo.getUserEmail() == null) || ("".equals(paramUserInfo.getUserEmail())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:USER_EMAIL");
      return localEnrollResult;
    }
    if ((paramUserInfo.getCertReqChallenge() == null) || ("".equals(paramUserInfo.getCertReqChallenge())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:CERT_REQ_CHALLENGE");
      return localEnrollResult;
    }
    if (paramUserInfo.getKeyMode() != null)
      if (paramUserInfo.getKeyMode().equals("ENROLL"))
      {
        if (paramUserInfo.getCertReqBuffer() == null)
        {
          localEnrollResult.setReturnCode("A002");
          localEnrollResult.setExtMessage("缺少必要参数:CERT_REQ_BUF");
          return localEnrollResult;
        }
      }
      else
      {
        if (!paramUserInfo.getKeyMode().equals("DOWNLOAD"))
          break label452;
        if (paramUserInfo.getCertReqBuffer() != null)
        {
          log.debug("DOWNLOAD模式私钥在获取时产生，CERT_REQ_BUF被置为null");
          paramUserInfo.setCertReqBuffer(null);
        }
      }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    addUserInfoToProperties(paramUserInfo, localProperties1);
    if ((paramUserInfo.getPasscode() != null) && (!"".equals(paramUserInfo.getPasscode())))
      localProperties1.setProperty("PASSCODE", paramUserInfo.getPasscode());
    if ((paramUserInfo.getPasscodeEx() != null) && (!"".equals(paramUserInfo.getPasscodeEx())))
      localProperties1.setProperty("PASSCODEEX", paramUserInfo.getPasscodeEx());
    localProperties1.setProperty("OPERATION", "EEEnroll");
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    localProperties1.setProperty("CERT_REQ_BUF_TYPE", "PKCS10");
    ifNotNullThenAdd(localProperties1, "KEYMODE", paramUserInfo.getKeyMode());
    ifNotExistThenAdd(localProperties1, "KEYMODE", "ENROLL");
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localEnrollResult.setReturnCode(l);
      if ("A115".equals(localEnrollResult.getHexCode()))
        localEnrollResult.setSuccess(true);
      label452: 
      while ((l != 0L) && (!"A119".equals(localEnrollResult.getHexCode())))
      {
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localEnrollResult.getMessage());
        return localEnrollResult;
        localEnrollResult.setReturnCode("A002");
        localEnrollResult.setExtMessage("参数设置错误：KEYMODE只能取值为ENROLL或DOWNLOAD");
        return localEnrollResult;
      }
      PickupResult localPickupResult = new PickupResult();
      localPickupResult.setReturnCode(l);
      localPickupResult.setSuccess(true);
      setPickupResultCharacter(localProperties2, localPickupResult);
      log.debug(localPickupResult.getMessage());
      return localPickupResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localEnrollResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public OperationResult enrollPfx(UserInfo paramUserInfo)
    throws RaServiceUnavailable
  {
    EnrollResult localEnrollResult = new EnrollResult();
    if (this.accountHash == null)
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localEnrollResult;
    }
    if ((paramUserInfo.getUserName() == null) || ("".equals(paramUserInfo.getUserName())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:USER_NAME（CommonName）");
      return localEnrollResult;
    }
    if ((paramUserInfo.getUserEmail() == null) || ("".equals(paramUserInfo.getUserEmail())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:USER_EMAIL");
      return localEnrollResult;
    }
    if ((paramUserInfo.getCertReqChallenge() == null) || ("".equals(paramUserInfo.getCertReqChallenge())))
    {
      localEnrollResult.setReturnCode("A002");
      localEnrollResult.setExtMessage("缺少必要参数:CERT_REQ_CHALLENGE");
      return localEnrollResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    addUserInfoToProperties(paramUserInfo, localProperties1);
    localProperties1.setProperty("OPERATION", "EEEnroll");
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    localProperties1.setProperty("CERT_REQ_BUF_TYPE", "PKCS10");
    localProperties1.setProperty("KEYMODE", "ENROLL");
    ifNotNullThenAdd(localProperties1, "KEYMODE", paramUserInfo.getKeyMode());
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localEnrollResult.setReturnCode(l);
      if ("A115".equals(localEnrollResult.getHexCode()))
        localEnrollResult.setSuccess(true);
      while ((l != 0L) && (!"A119".equals(localEnrollResult.getHexCode())))
      {
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localEnrollResult.getMessage());
        return localEnrollResult;
      }
      PickupResult localPickupResult = new PickupResult();
      localPickupResult.setReturnCode(l);
      localPickupResult.setSuccess(true);
      setPickupResultCharacter(localProperties2, localPickupResult);
      log.debug(localPickupResult.getMessage());
      return localPickupResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localEnrollResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public String getAccountHash()
  {
    return this.accountHash;
  }

  public Vector getAvailableRaServices()
  {
    return this.availableIcaServices;
  }

  public RaConnection getRaConnection(int paramInt)
    throws RaServiceUnavailable
  {
    Vector localVector = (Vector)this.availableIcaServices.clone();
    int i = localVector.size();
    Random localRandom = new Random();
    while (true)
    {
      if (localVector.size() <= 0)
        throw new RaServiceUnavailable("没有有效的RA服务");
      int j = Math.abs(localRandom.nextInt() % i);
      String str = (String)localVector.elementAt(j);
      try
      {
        RaConnection localRaConnection = RaFactory.getConnection(str);
        if (localRaConnection != null)
        {
          log.debug("连接[" + str + "]成功");
          return localRaConnection;
        }
      }
      catch (UnknownHostException localUnknownHostException)
      {
        log.warn("未知主机[" + str + "]");
        localVector.remove(j);
        i = localVector.size();
      }
      catch (IOException localIOException)
      {
        while (true)
          log.warn(localIOException.getMessage() + " [" + str + "]");
      }
    }
  }

  public PickupResult pickupCert(String paramString)
    throws RaServiceUnavailable
  {
    return pickupCert(paramString, null, null);
  }

  public PickupResult pickupCert(String paramString1, String paramString2, String paramString3)
    throws RaServiceUnavailable
  {
    PickupResult localPickupResult = new PickupResult();
    if (this.accountHash == null)
    {
      localPickupResult.setReturnCode("A002");
      localPickupResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localPickupResult;
    }
    if ((paramString1 == null) || ("".equals(paramString1)))
    {
      localPickupResult.setReturnCode("A002");
      localPickupResult.setExtMessage("缺少必要参数:CERT_PIN");
      return localPickupResult;
    }
    String str;
    if (((paramString2 == null) || ("".equals(paramString2))) && ((paramString3 == null) || ("".equals(paramString3))))
      str = "ENROLL";
    while (true)
    {
      Properties localProperties1 = new Properties();
      Properties localProperties2 = new Properties();
      localProperties1.setProperty("CERT_PIN", paramString1);
      localProperties1.setProperty("OPERATION", "EEPickup");
      localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
      localProperties1.setProperty("KEYMODE", str);
      ifNotNullThenAdd(localProperties1, "CERT_REQ_CHALLENGE", paramString2);
      ifNotNullThenAdd(localProperties1, "CERT_REQ_BUF", paramString3);
      if (localProperties1.containsKey("CERT_REQ_BUF"))
        localProperties1.setProperty("CERT_REQ_BUF_TYPE", "PKCS10");
      localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
      RaConnection localRaConnection = null;
      try
      {
        localRaConnection = getRaConnection(this.timeOut);
        long l = localRaConnection.request(localProperties1, localProperties2);
        localPickupResult.setReturnCode(l);
        if (l == 0L)
        {
          localPickupResult.setSuccess(true);
          setPickupResultCharacter(localProperties2, localPickupResult);
        }
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localPickupResult.getMessage());
        return localPickupResult;
        if ((paramString2 == null) || ("".equals(paramString2)) || (paramString3 == null) || ("".equals(paramString3)))
        {
          localPickupResult.setReturnCode("A002");
          localPickupResult.setExtMessage("缺少必要参数:CERT_REQ_CHALLENGE或CERT_REQ_BUF");
          return localPickupResult;
        }
        str = "DOWNLOAD";
      }
      catch (IOException localIOException)
      {
        while (true)
        {
          localPickupResult.setReturnCode(1L);
          if (localRaConnection != null)
            localRaConnection.close();
        }
      }
      finally
      {
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
  }

  public QueryResult queryCertByCertId(int paramInt, String paramString)
    throws RaServiceUnavailable
  {
    QueryResult localQueryResult = new QueryResult();
    if (this.accountHash == null)
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localQueryResult;
    }
    if (paramInt <= 0)
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:CERT_ID");
      return localQueryResult;
    }
    if ((paramString == null) || ("".equals(paramString)))
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:sqlTemplateFileName");
      return localQueryResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.setProperty("OPERATION", "Query");
    ifNotNullThenAdd(localProperties1, "SQL_TEMPLATE_FILENAME", paramString);
    localProperties1.setProperty("CERT_ID", String.valueOf(paramInt));
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localQueryResult.setReturnCode(l);
      if (l == 0L)
      {
        setSqlResultCharacter(localProperties2, localQueryResult);
        String str = localProperties2.getProperty("SQL_RECORDS_COUNT");
        if ((str == null) || (Integer.valueOf(str).intValue() <= 0))
          break label276;
        localQueryResult.setResult(getCertInfo(localProperties2));
        localQueryResult.setTotal(1);
      }
      while (true)
      {
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localQueryResult.getMessage());
        return localQueryResult;
        label276: localQueryResult.setExtMessage("没有找到CERT_ID为" + paramInt + "的数字证书");
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localQueryResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public QueryResult queryCertBySerialNumber(String paramString1, String paramString2)
    throws RaServiceUnavailable
  {
    QueryResult localQueryResult = new QueryResult();
    if (this.accountHash == null)
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localQueryResult;
    }
    if ((paramString1 == null) || ("".equals(paramString1)))
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:CERT_SERIALNUMBER");
      return localQueryResult;
    }
    String str1 = CertUtils.getICAValidSerialNumber(paramString1);
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.setProperty("OPERATION", "Query");
    ifNotNullThenAdd(localProperties1, "SQL_TEMPLATE_FILENAME", paramString2);
    ifNotExistThenAdd(localProperties1, "SQL_TEMPLATE_FILENAME", "caCheckCertAccount");
    localProperties1.setProperty("CERT_SERIALNUMBER", str1);
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    while (true)
    {
      try
      {
        localRaConnection = getRaConnection(this.timeOut);
        long l1 = localRaConnection.request(localProperties1, localProperties2);
        localQueryResult.setReturnCode(l1);
        if (l1 == 0L)
        {
          setSqlResultCharacter(localProperties2, localQueryResult);
          if (paramString2 != null)
            continue;
          String str2 = localProperties2.getProperty("USER_ID");
          if (str2 == null)
          {
            localQueryResult.setExtMessage("没有找到序列号为" + str1 + "的数字证书");
            return localQueryResult;
          }
          localProperties1.clear();
          localProperties1.setProperty("SQL_TEMPLATE_FILENAME", "ra_UserCertDetail");
          localProperties1.setProperty("CERT_SERIALNUMBER", str1);
          localProperties1.setProperty("USER_ID", str2);
          localProperties1.setProperty("OPERATION", "Query");
          localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
          localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
          localProperties2.clear();
          long l2 = localRaConnection.request(localProperties1, localProperties2);
          localQueryResult.setReturnCode(l2);
          if (l2 == 0L)
          {
            setSqlResultCharacter(localProperties2, localQueryResult);
            String str3 = localProperties2.getProperty("SQL_RECORDS_COUNT");
            if ((str3 == null) || (Integer.valueOf(str3).intValue() <= 0))
              continue;
            localQueryResult.setResult(getCertInfo(localProperties2));
            localQueryResult.setTotal(1);
          }
        }
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localQueryResult.getMessage());
        return localQueryResult;
        localQueryResult.setExtMessage("没有找到序列号为" + str1 + "的数字证书");
        continue;
      }
      catch (IOException localIOException)
      {
        localQueryResult.setReturnCode(1L);
        if (localRaConnection == null)
          continue;
        localRaConnection.close();
        continue;
        String str4 = localProperties2.getProperty("SQL_RECORDS_COUNT");
        if ((str4 != null) && (Integer.valueOf(str4).intValue() > 0))
        {
          localQueryResult.setResult(getCertInfo(localProperties2));
          localQueryResult.setTotal(1);
          continue;
        }
      }
      finally
      {
        if (localRaConnection != null)
          localRaConnection.close();
      }
      localQueryResult.setExtMessage("没有找到序列号为" + str1 + "的数字证书");
    }
  }

  public QueryResult queryCerts(UserInfo paramUserInfo, int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3)
    throws RaServiceUnavailable
  {
    QueryResult localQueryResult = new QueryResult();
    if (this.accountHash == null)
    {
      localQueryResult.setReturnCode("A002");
      localQueryResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localQueryResult;
    }
    Properties localProperties1 = new Properties();
    Vector localVector1 = new Vector();
    ifNotNullThenAdd(localProperties1, "NEXT_RESULT_TAG", paramString2);
    ifNotExistThenAdd(localProperties1, "NEXT_RESULT_TAG", "USER_ID");
    ifNotNullThenAdd(localProperties1, "TOTAL_TAG", paramString3);
    ifNotExistThenAdd(localProperties1, "TOTAL_TAG", "USER_TOTAL");
    if (paramInt1 <= 0)
      paramInt1 = 1;
    int i = paramInt2 * (paramInt1 - 1);
    localProperties1.put("SQL_CONTINUE", "YES");
    localProperties1.put("SQL_RECORDS_INDEX", String.valueOf(i));
    localProperties1.put("SQL_WANTTOGET_RECORDS", String.valueOf(paramInt2));
    ifNotNullThenAdd(localProperties1, "SQL_TEMPLATE_FILENAME", paramString1);
    ifNotExistThenAdd(localProperties1, "SQL_TEMPLATE_FILENAME", "UserCertQueryAll");
    addUserInfoToProperties(paramUserInfo, localProperties1);
    localProperties1.setProperty("OPERATION", "Query");
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      PipeInteger localPipeInteger = new PipeInteger();
      Properties localProperties2 = new Properties();
      long l = localRaConnection.request(localProperties1, localVector1, localPipeInteger, localProperties2);
      localQueryResult.setReturnCode(l);
      setSqlResultCharacter(localProperties2, localQueryResult);
      Vector localVector2;
      if (l == 0L)
        localVector2 = new Vector();
      for (int j = 0; ; j++)
      {
        if (j >= localVector1.size())
        {
          localQueryResult.setPageSize(paramInt2);
          localQueryResult.setTotal(localPipeInteger.getValue());
          log.debug("满足条件的记录一共有[" + localPipeInteger.getValue() + "]条");
          localQueryResult.setResults(localVector2);
          if (localRaConnection != null)
            localRaConnection.close();
          log.debug(localQueryResult.getMessage());
          return localQueryResult;
        }
        localVector2.add(getCertInfo((Properties)localVector1.elementAt(j)));
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localQueryResult.setReturnCode(1L);
        localIOException.printStackTrace();
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public OperationResult renewCert(RenewInfo paramRenewInfo)
    throws RaServiceUnavailable
  {
    RenewResult localRenewResult = new RenewResult();
    if (this.accountHash == null)
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localRenewResult;
    }
    if ((paramRenewInfo.getOrigCertSerialNumber() == null) || ("".equals(paramRenewInfo.getOrigCertSerialNumber())))
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("缺少必要参数:ORIG_CERT_SERIALNUMBER");
      return localRenewResult;
    }
    if ((paramRenewInfo.getOrigCert() == null) || ("".equals(paramRenewInfo.getOrigCert())))
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("缺少必要参数:ORIG_CERT");
      return localRenewResult;
    }
    if ((paramRenewInfo.getPkcsInformation() == null) || ("".equals(paramRenewInfo.getPkcsInformation())))
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("缺少必要参数:PKCSINFORMATION");
      return localRenewResult;
    }
    if ((paramRenewInfo.getCertReqBuf() == null) || ("".equals(paramRenewInfo.getCertReqBuf())))
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("缺少必要参数:CERT_REQ_BUF");
      return localRenewResult;
    }
    if (("PASSCODE".equals(paramRenewInfo.getRenewMode())) && (paramRenewInfo.getPasscode() == null))
    {
      localRenewResult.setReturnCode("A002");
      localRenewResult.setExtMessage("PASSCODE更新模式缺少必要参数:PASSCODE");
      return localRenewResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    ifNotNullThenAdd(localProperties1, "RENEWMODE", paramRenewInfo.getRenewMode());
    ifNotExistThenAdd(localProperties1, "RENEWMODE", "MANUAL");
    ifNotNullThenAdd(localProperties1, "PASSCODE", paramRenewInfo.getPasscode());
    ifNotNullThenAdd(localProperties1, "CERT_REQ_CHALLENGE", paramRenewInfo.getCertReqChallenge());
    ifNotNullThenAdd(localProperties1, "CERT_REQ_CHALLENGE_OLD", paramRenewInfo.getCertReqChallengeOld());
    localProperties1.setProperty("ORIG_CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(paramRenewInfo.getOrigCertSerialNumber()));
    localProperties1.setProperty("ORIG_CERT", paramRenewInfo.getOrigCert());
    localProperties1.setProperty("PKCSINFORMATION", paramRenewInfo.getPkcsInformation());
    localProperties1.setProperty("CERT_REQ_BUF", paramRenewInfo.getCertReqBuf());
    localProperties1.setProperty("CERT_REQ_BUF_TYPE", "PKCS10");
    localProperties1.setProperty("OPERATION", "EERenewal");
    localProperties1.setProperty("ACCOUNT_HASH", this.accountHash);
    ifNotNullThenAdd(localProperties1, "CERT_REQ_COMMENT", paramRenewInfo.getCertReqComment());
    ifNotNullThenAdd(localProperties1, "CERT_REQ_OVERRIDE_VALIDITY", paramRenewInfo.getCertReqOverrideValidity());
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localRenewResult.setReturnCode(l);
      if ("A115".equals(localRenewResult.getHexCode()))
        localRenewResult.setSuccess(true);
      while (l != 0L)
      {
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localRenewResult.getMessage());
        return localRenewResult;
      }
      PickupResult localPickupResult = new PickupResult();
      localPickupResult.setReturnCode(l);
      localPickupResult.setSuccess(true);
      setPickupResultCharacter(localProperties2, localPickupResult);
      log.debug(localPickupResult.getMessage());
      return localPickupResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localRenewResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public RevokeResult revokeCert(String paramString1, String paramString2, String paramString3)
    throws RaServiceUnavailable
  {
    RevokeResult localRevokeResult = new RevokeResult();
    if (this.accountHash == null)
    {
      localRevokeResult.setReturnCode("A002");
      localRevokeResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localRevokeResult;
    }
    if ((paramString1 == null) || ("".equals(paramString1)))
    {
      localRevokeResult.setReturnCode("A002");
      localRevokeResult.setExtMessage("缺少必要参数:CERT_SERIALNUMBER");
      return localRevokeResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.put("CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(paramString1));
    localProperties1.put("OPERATION", "EERevoke");
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    localProperties1.put("CERT_REQ_CHALLENGE", paramString2);
    if (paramString3 != null);
    while (true)
    {
      localProperties1.put("CERT_REVOKE_REASON", paramString3);
      RaConnection localRaConnection = null;
      try
      {
        localRaConnection = getRaConnection(this.timeOut);
        long l = localRaConnection.request(localProperties1, localProperties2);
        localRevokeResult.setReturnCode(l);
        if (l == 0L)
        {
          localRevokeResult.setSuccess(true);
          localRevokeResult.setCertRevokeDate(localProperties2.getProperty("CERT_REVOKE_DATE"));
          localRevokeResult.setCertSerialNumber(localProperties2.getProperty("CERT_SERIALNUMBER"));
          localRevokeResult.setCertRevokeReason(localProperties2.getProperty("CERT_REVOKE_REASON"));
        }
        if (localRaConnection != null)
          localRaConnection.close();
        log.debug(localRevokeResult.getMessage());
        return localRevokeResult;
        paramString3 = "Key compromise";
      }
      catch (IOException localIOException)
      {
        while (true)
        {
          localRevokeResult.setReturnCode(1L);
          if (localRaConnection != null)
            localRaConnection.close();
        }
      }
      finally
      {
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
  }

  public void setAccountHash(String paramString)
  {
    this.accountHash = paramString;
  }

  public void setAccountHash(String paramString1, String paramString2)
  {
    this.accountOrg = paramString1;
    this.accountOrgUnit = paramString2;
    this.accountHash = CipherUtils.md5(paramString1 + paramString2).toUpperCase();
  }

  public void setAvailableRaServices(Vector paramVector)
  {
    this.availableIcaServices = paramVector;
  }

  public void setTimeOut(int paramInt)
  {
    this.timeOut = paramInt;
  }

  public SuspendResult suspendCert(String paramString)
    throws RaServiceUnavailable
  {
    SuspendResult localSuspendResult = new SuspendResult();
    if (this.accountHash == null)
    {
      localSuspendResult.setReturnCode("A002");
      localSuspendResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localSuspendResult;
    }
    String str = getValidAdminCertSerialNumber();
    if (str == null)
    {
      localSuspendResult.setReturnCode("A002");
      localSuspendResult.setExtMessage("缺少必要参数:ADMIN_CERT_SERIALNUMBER");
      return localSuspendResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.put("OPERATION", "AdminSuspend");
    localProperties1.put("ICA_ADMIN_CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(str));
    localProperties1.put("CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(paramString));
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localSuspendResult.setReturnCode(l);
      if (l == 0L)
      {
        localSuspendResult.setSuccess(true);
        localSuspendResult.setCertSuspendDate(localProperties2.getProperty("CERT_SUSPEND_DATE"));
        localSuspendResult.setCertSerialNumber(localProperties2.getProperty("CERT_SERIALNUMBER"));
      }
      if (localRaConnection != null)
        localRaConnection.close();
      log.debug(localSuspendResult.getMessage());
      return localSuspendResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localSuspendResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }

  public UnSuspendResult unsuspendCert(String paramString)
    throws RaServiceUnavailable
  {
    UnSuspendResult localUnSuspendResult = new UnSuspendResult();
    if (this.accountHash == null)
    {
      localUnSuspendResult.setReturnCode("A002");
      localUnSuspendResult.setExtMessage("缺少必要参数:ACCOUNT_HASH");
      return localUnSuspendResult;
    }
    String str = getValidAdminCertSerialNumber();
    if (str == null)
    {
      localUnSuspendResult.setReturnCode("A002");
      localUnSuspendResult.setExtMessage("缺少必要参数:ADMIN_CERT_SERIALNUMBER");
      return localUnSuspendResult;
    }
    Properties localProperties1 = new Properties();
    Properties localProperties2 = new Properties();
    localProperties1.put("OPERATION", "AdminResume");
    localProperties1.put("ICA_ADMIN_CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(str));
    localProperties1.put("CERT_SERIALNUMBER", CertUtils.getICAValidSerialNumber(paramString));
    localProperties1.setProperty("TIMEOUT", String.valueOf(this.timeOut));
    RaConnection localRaConnection = null;
    try
    {
      localRaConnection = getRaConnection(this.timeOut);
      long l = localRaConnection.request(localProperties1, localProperties2);
      localUnSuspendResult.setReturnCode(l);
      if (l == 0L)
      {
        localUnSuspendResult.setSuccess(true);
        localUnSuspendResult.setCertSuspendDate(localProperties2.getProperty("CERT_SUSPEND_DATE"));
        localUnSuspendResult.setCertSerialNumber(localProperties2.getProperty("CERT_SERIALNUMBER"));
      }
      if (localRaConnection != null)
        localRaConnection.close();
      log.debug(localUnSuspendResult.getMessage());
      return localUnSuspendResult;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localUnSuspendResult.setReturnCode(1L);
        if (localRaConnection != null)
          localRaConnection.close();
      }
    }
    finally
    {
      if (localRaConnection != null)
        localRaConnection.close();
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.itrus.raapi.implement.RaCertManagerImpl
 * JD-Core Version:    0.6.2
 */